#include "MyMatrix.h"

#include <vector>

using std::vector;

MyMatrix::MyMatrix(double matrix[], int m)
{
	this->matrix = new vector<double>(&matrix[0], &matrix[m]);
	this->m = m;
}

template <size_t M, size_t N>
MyMatrix::MyMatrix(double (&matrix)[M][N], int m, int n)
{
	this->twoDMatrix = new vector<vector<double> *>(m);
	this->m = m;
	this->n = n;

	for(int i = 0; i < this->m; i++)
	{
		vector<double> * v = new vector<double>(n);

		for(int j = 0; j < this->n; j++)
		{
			double d = matrix[i][j];
			v->at(j) = 0;;
		}

		this->twoDMatrix->at(i) = v;
	}
}


MyMatrix::~MyMatrix(void)
{
}

void MyMatrix::Add(double operand)
{
	for(int i = 0; i < this->m; i++)
	{
		this->matrix->at(i) += operand;
	}
}

void MyMatrix::Add(MyMatrix operand)
{
	for(int i = 0; i < this->m; i++)
	{
		this->matrix->at(i) += operand.matrix->at(i);
	}
}

void MyMatrix::Subtract(double operand)
{
	for(int i = 0; i < this->m; i++)
	{
		this->matrix->at(i) -= operand;
	}
}

void MyMatrix::Subtract(MyMatrix operand)
{
	for(int i = 0; i < this->m; i++)
	{
		this->matrix->at(i) -= operand.matrix->at(i);
	}
}

void MyMatrix::Multiply(double operand)
{
	for(int i = 0; i < this->m; i++)
	{
		this->matrix->at(i) *= operand;
	}
}

void MyMatrix::Multiply(MyMatrix operand)
{
	for(int i = 0; i < this->m; i++)
	{
		this->matrix->at(i) *= operand.matrix->at(i);
	}
}

void MyMatrix::Divide(double operand)
{
	for(int i = 0; i < this->m; i++)
	{
		this->matrix->at(i) /= operand;
	}
}

void MyMatrix::Divide(MyMatrix operand)
{
	for(int i = 0; i < this->m; i++)
	{
		this->matrix->at(i) /= operand.matrix->at(i);
	}
}
